#ifndef XHOLDPATTERN_H_INCLUDED
#define XHOLDPATTERN_H_INCLUDED

/*
    XHoldingPattern
    Copyright (C) 2009 Mike Gehl

    X-Plane Plugin SDK
    Copyright (C) Sandy Barbour and Ben Supnik

    This file is part of XHoldingPattern.

    XHoldingPattern is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    XHoldingPattern is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with XHoldingPattern.  If not, see <http://www.gnu.org/licenses/>.
    ---------------------------------------------------------------------------
    xHoldPattern.h
    Copyright (C) Mike Gehl 2009 <mjgehl@gmail.com>
*/

#include "XPLMDataAccess.h"
#include "XPLMMenus.h"
#include "XPLMDisplay.h"
#include "XPLMGraphics.h"

/* Program Name*/
static const char* PRG_NAME = "XHoldPattern";

/* Version Number*/
static const char* PRG_VERSION = "1.0";

/* Copyright */
static const char* PRG_COPYRIGHT = "Copyright (C) Mike Gehl 2009";

/* Number of seconds to delay before updating course */
static const float HOLDPAT_INTERVAL = 1.0;

/* Status of flight recorder. OFF or ON */
typedef enum
{
    HOLDPAT_OFF,
    HOLDPAT_ON
} hold_pattern_status;

typedef enum
{
    HOLDPAT_MENU_ON,
    HOLDPAT_MENU_OFF,
    HOLDPAT_MENU_ABOUT
} hold_pattern_menus;


/**
 * Required: This is a forced API (must be included) by the SDK.
 * It is called once when the plugin is loaded. (constructor)
 *
 * Allocate any permanent resources, do initialization, and register any other
 * callbacks. This is where the user interface is initialized.
 * Also return the plugin's name, signature, and a description to the XPLM.
 *
 * @param outName Name of the plugin
 * @param outSig Plugin signature
 * @param outDesc Plugin Description
 * @return 1 on successful init
 */
PLUGIN_API int XPluginStart(char *, char *, char *);

/**
 * Required: This is a forced API (must be included) by the SDK.
 * It is called once when the plugin is unloaded. (destructor)
 *
 * De-allocate any callbacks, free memory and close any open files.
 */
PLUGIN_API void	XPluginStop(void);

/**
 * Required: This is a forced API (must be included) by the SDK.
 * This is called when the plugin is enabled, either right after it is loaded
 * or when a user decides to enable it via the Plugin Manager.
 *
 * This is called when the plugin is enabled.
 * @return  1 if enable was successful
 */
PLUGIN_API int XPluginEnable(void);

/**
 * Required: This is a forced API (must be included) by the SDK.
 * This is called when the plugin is disabled, either just before it is
 * unloaded or when a user decides to disable it via the Plugin Manager.
 */
PLUGIN_API void XPluginDisable(void);

/**
 * Required: This is a forced API (must be included) by the SDK.
 * Used or not, we must make provision to receive messages from keyboard,
 * mouse, X-Plane and other plugins.
 *
 * Not used in this plugin
 *
 * @param inFromWho
 * @param inMessage
 * @param inParam
 */
PLUGIN_API void XPluginReceiveMessage(XPLMPluginID, long, void *);

/**
 * Determine which XFlightRec menu item was selected and Start or
 * Stop the recorder.
 *
 * @param inMenuRef Void pointer to the XFlightRec menu
 * @param inItemRef Void pointer to the XFlightRec menu item selected
 */
void holdpat_menu_callback(void *, void *);

/**
 * Determine which XFlightRec menu item was selected and Start or
 * Stop the recorder.
 *
 * @param inElapsedSinceLastCall
 * @param inElapsedTimeSinceLastFlightLoop
 * @param inCounter
 * @param inRefcon
 *
 * @return Return Time interval to be called again.
 */
float holdpat_loop_callback(float, float, int,  void *);



void holdpat_window_callback(XPLMWindowID, void *);

/**
 * Stop the Flight Data Recorder. Close any open file
 */
void holdpat_stop(void);

/**
 * Start the Flight Data Recorder. Open and overwrite a previous data file.
 */
void holdpat_start(void);

/* X-Plane Dataref:  sim/time/zulu_time_sec */
XPLMDataRef gZuluTime;


/* X-Plane Dataref: sim/flightmodel/position/elevation */
XPLMDataRef gPlaneAlt;

/* X-Plane Dataref: sim/flightmodel/position/theta */
XPLMDataRef gPlanePitch;

/* X-Plane Dataref: sim/flightmodel/position/phi */
XPLMDataRef gPlaneRoll;

/* X-Plane Dataref: sim/flightmodel/position/psi */
XPLMDataRef gPlaneHeading;

/* X-Plane Dataref: sim/flightmodel/position/indicated_airspeed */
XPLMDataRef gPlaneIAS;

XPLMDataRef gPlaneTAS;
XPLMDataRef gWindSpeed;
XPLMDataRef gWindDirection;



#endif // XHOLDPATTERN_H_INCLUDED
